#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

using namespace std;

int main()
{
    extern char** environ;

    //cout << "打印环境变量" << endl;
    //for (int i = 0; environ[i]; i++)
    //{
    //    printf("%d: %s\n", i, environ[i]);
    //}

    cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
    //根据环境变量名，获取环境变量的内容
    cout << "PATH:" << getenv("PATH") << endl;
    cout << "----------------------------------------------" << endl;
    cout << "MYPATH:" << getenv("MYPATH") << endl;
    cout << "----------------------------------------------" << endl;
    
    //程序崩溃了 -- 因为环境变量里根本就没有MYPATH  
    
    cout << "Hello World!" << endl;
    cout << "Hello World!" << endl;
    cout << "Hello World!" << endl;
    cout << "Hello World!" << endl;

    return 0;
}
